package sv.gob.mh.dgii.model;

// Generated Dec 12, 2007 1:25:05 PM by Hibernate Tools 3.2.0.CR1

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import sv.gob.mh.dgii.common.Utils;

/**
 * RcDomicilio generated by hbm2java
 */
@Entity
@Table(name = "RC_DOMICILIO", schema = "RUC")
@SequenceGenerator(name="SEQ_RC_DOMICILIO" , sequenceName="SEQ_RC_DOMICILIO")
public class RcDomicilio implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 8408472736132357886L;
	private Long ircDomicilio;
	private String nit;	
	private TbDomicilio tbDomicilio;
	private TbMunicipio tbMunicipio;
	private Date fidomicilio;
	private String ddetalle;
	private String scalle;
	private String napto;
	private String scomplemento;
	private String scolonia;
	private String nnumero;
	private String ntelefono;
	private String nfax;
	private Date ffdomicilio;
	private String cusuario;
	private String czona;
	private String semail;
	private Long ncomercial;
	private String nfolioIndice;
	private String nsucursal;
	private String snomComerSuc;

	public RcDomicilio() {
	}

	public RcDomicilio(Long ircDomicilio, String nit, TbDomicilio tbDomicilio,
			TbMunicipio tbMunicipio, Date fidomicilio, String cusuario) {
		this.ircDomicilio = ircDomicilio;
		this.nit = nit;
		this.tbDomicilio = tbDomicilio;
		this.tbMunicipio = tbMunicipio;
		this.fidomicilio = fidomicilio;
		this.cusuario = cusuario;
	}

	public RcDomicilio(Long ircDomicilio, String nit, TbDomicilio tbDomicilio,
			TbMunicipio tbMunicipio, Date fidomicilio, String ddetalle,
			String scalle, String napto, String scomplemento, String scolonia,
			String nnumero, String ntelefono, String nfax, Date ffdomicilio,
			String cusuario, String czona, String semail, Long ncomercial,
			String nfolioIndice, String nsucursal, String snomComerSuc) {
		this.ircDomicilio = ircDomicilio;
		this.nit = nit;
		this.tbDomicilio = tbDomicilio;
		this.tbMunicipio = tbMunicipio;
		this.fidomicilio = fidomicilio;
		this.ddetalle = ddetalle;
		this.scalle = scalle;
		this.napto = napto;
		this.scomplemento = scomplemento;
		this.scolonia = scolonia;
		this.nnumero = nnumero;
		this.ntelefono = ntelefono;
		this.nfax = nfax;
		this.ffdomicilio = ffdomicilio;
		this.cusuario = cusuario;
		this.czona = czona;
		this.semail = semail;
		this.ncomercial = ncomercial;
		this.nfolioIndice = nfolioIndice;
		this.nsucursal = nsucursal;
		this.snomComerSuc = snomComerSuc;
	}

	@Id
	@Column(name = "I_RC_DOMICILIO", unique = true, nullable = false, precision = 10, scale = 0)
	@GeneratedValue(strategy=GenerationType.AUTO, generator="SEQ_RC_DOMICILIO")
	public Long getIrcDomicilio() {
		return this.ircDomicilio;
	}

	public void setIrcDomicilio(Long ircDomicilio) {
		this.ircDomicilio = ircDomicilio;
	}

	
	@Column(name = "NIT", nullable = false, length=14)
	public String getNit() {
		return this.nit;
	}

	public void setNit(String nit) {
		this.nit = nit;
	}

	@ManyToOne(fetch = FetchType.LAZY )
	@JoinColumn(name = "C_DOMICILIO", nullable = false )
	public TbDomicilio getTbDomicilio() {
		return this.tbDomicilio;
	}

	public void setTbDomicilio(TbDomicilio tbDomicilio) {
		this.tbDomicilio = tbDomicilio;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumns( {
			@JoinColumn(name = "C_DEPARTAMENTO", referencedColumnName = "C_DEPARTAMENTO", nullable = false),
			@JoinColumn(name = "C_MUNICIPIO", referencedColumnName = "C_MUNICIPIO", nullable = false) })
	public TbMunicipio getTbMunicipio() {
		return this.tbMunicipio;
	}

	public void setTbMunicipio(TbMunicipio tbMunicipio) {
		this.tbMunicipio = tbMunicipio;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "FI_DOMICILIO", nullable = false)
	public Date getFidomicilio() {
		return this.fidomicilio;
	}

	public void setFidomicilio(Date fidomicilio) {
		this.fidomicilio = fidomicilio;
	}

	@Column(name = "D_DETALLE", length = 60)
	public String getDdetalle() {
		return this.ddetalle;
	}

	public void setDdetalle(String ddetalle) {
		this.ddetalle = ddetalle;
	}

	@Column(name = "S_CALLE", length = 100)
	public String getScalle() {
		return this.scalle;
	}

	public void setScalle(String scalle) {
		this.scalle = scalle;
	}

	@Column(name = "N_APTO", length = 10)
	public String getNapto() {
		return this.napto;
	}

	public void setNapto(String napto) {
		this.napto = napto;
	}

	@Column(name = "S_COMPLEMENTO", length = 100)
	public String getScomplemento() {
		return this.scomplemento;
	}

	public void setScomplemento(String scomplemento) {
		this.scomplemento = scomplemento;
	}

	@Column(name = "S_COLONIA", length = 100)
	public String getScolonia() {
		return this.scolonia;
	}

	public void setScolonia(String scolonia) {
		this.scolonia = scolonia;
	}

	@Column(name = "N_NUMERO", length = 8)
	public String getNnumero() {
		return this.nnumero;
	}

	public void setNnumero(String nnumero) {
		this.nnumero = nnumero;
	}

	@Column(name = "N_TELEFONO", length = 15)
	public String getNtelefono() {
		return this.ntelefono;
	}

	public void setNtelefono(String ntelefono) {
		this.ntelefono = ntelefono;
	}

	@Column(name = "N_FAX", length = 8)
	public String getNfax() {
		return this.nfax;
	}

	public void setNfax(String nfax) {
		this.nfax = nfax;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "FF_DOMICILIO")
	public Date getFfdomicilio() {
		return this.ffdomicilio;
	}

	public void setFfdomicilio(Date ffdomicilio) {
		this.ffdomicilio = ffdomicilio;
	}

	@Column(name = "C_USUARIO", nullable = false, length = 30)
	public String getCusuario() {
		return this.cusuario;
	}

	public void setCusuario(String cusuario) {
		this.cusuario = cusuario;
	}

	@Column(name = "C_ZONA", length = 2)
	public String getCzona() {
		return this.czona;
	}

	public void setCzona(String czona) {
		this.czona = czona;
	}

	@Column(name = "S_EMAIL", length = 100)
	public String getSemail() {
		return this.semail;
	}

	public void setSemail(String semail) {
		this.semail = semail;
	}

	@Column(name = "N_COMERCIAL", precision = 10, scale = 0)
	public Long getNcomercial() {
		return this.ncomercial;
	}

	public void setNcomercial(Long ncomercial) {
		this.ncomercial = ncomercial;
	}

	@Column(name = "N_FOLIO_INDICE", length = 20)
	public String getNfolioIndice() {
		return this.nfolioIndice;
	}

	public void setNfolioIndice(String nfolioIndice) {
		this.nfolioIndice = nfolioIndice;
	}

	@Column(name = "N_SUCURSAL", length = 3)
	public String getNsucursal() {
		return this.nsucursal;
	}

	public void setNsucursal(String nsucursal) {
		this.nsucursal = nsucursal;
	}

	@Column(name = "S_NOM_COMER_SUC", length = 100)
	public String getSnomComerSuc() {
		return this.snomComerSuc;
	}

	public void setSnomComerSuc(String snomComerSuc) {
		this.snomComerSuc = snomComerSuc;
	}
        
        @Transient
        public String getFullDireccion() {				
		StringBuilder sb = new StringBuilder();
		sb.append("").append(Utils.nvl(getScalle(), ""));
		sb.append(Utils.emptyOrOther(getScalle(), " ",", "));
		sb.append("").append(Utils.nvl(getNapto(), ""));
		sb.append(Utils.emptyOrOther(getNapto(), " ",", "));
		sb.append("").append(Utils.nvl(getScolonia(), ""));
		sb.append(Utils.emptyOrOther(getScolonia(), " ",", "));
		sb.append("").append(Utils.nvl(getNnumero(),""));
		sb.append(Utils.emptyOrOther(getNnumero(), " ",", "));
		sb.append("").append(Utils.nvl(getScomplemento(),""));
		sb.append(Utils.emptyOrOther(getScomplemento(), " ",", "));
		sb.append("").append(Utils.nvl(getTbMunicipio().getDmunicipio(),""));		
		sb.append(Utils.emptyOrOther(getTbMunicipio().getDmunicipio(), " ",", "));
		sb.append("").append(Utils.nvl(getTbMunicipio().getTbDepartamento().getDdepartamento(),""));
		return sb.toString();
	}

	@Override
	public String toString() {
		return "RcDomicilio [ircDomicilio=" + ircDomicilio + ", nit=" + nit
				+ ", tbDomicilio=" + tbDomicilio + ", tbMunicipio="
				+ tbMunicipio + ", fidomicilio=" + fidomicilio + ", ddetalle="
				+ ddetalle + ", scalle=" + scalle + ", napto=" + napto
				+ ", scomplemento=" + scomplemento + ", scolonia=" + scolonia
				+ ", nnumero=" + nnumero + ", ntelefono=" + ntelefono
				+ ", nfax=" + nfax + ", ffdomicilio=" + ffdomicilio
				+ ", cusuario=" + cusuario + ", czona=" + czona + ", semail="
				+ semail + ", ncomercial=" + ncomercial + ", nfolioIndice="
				+ nfolioIndice + ", nsucursal=" + nsucursal + ", snomComerSuc="
				+ snomComerSuc + "]";
	}

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 89 * hash + (this.ircDomicilio != null ? this.ircDomicilio.hashCode() : 0);
        hash = 89 * hash + (this.nit != null ? this.nit.hashCode() : 0);
        hash = 89 * hash + (this.tbDomicilio != null ? this.tbDomicilio.hashCode() : 0);
        hash = 89 * hash + (this.tbMunicipio != null ? this.tbMunicipio.hashCode() : 0);
        hash = 89 * hash + (this.fidomicilio != null ? this.fidomicilio.hashCode() : 0);
        hash = 89 * hash + (this.ddetalle != null ? this.ddetalle.hashCode() : 0);
        hash = 89 * hash + (this.scalle != null ? this.scalle.hashCode() : 0);
        hash = 89 * hash + (this.napto != null ? this.napto.hashCode() : 0);
        hash = 89 * hash + (this.scomplemento != null ? this.scomplemento.hashCode() : 0);
        hash = 89 * hash + (this.scolonia != null ? this.scolonia.hashCode() : 0);
        hash = 89 * hash + (this.nnumero != null ? this.nnumero.hashCode() : 0);
        hash = 89 * hash + (this.ntelefono != null ? this.ntelefono.hashCode() : 0);
        hash = 89 * hash + (this.nfax != null ? this.nfax.hashCode() : 0);
        hash = 89 * hash + (this.ffdomicilio != null ? this.ffdomicilio.hashCode() : 0);
        hash = 89 * hash + (this.cusuario != null ? this.cusuario.hashCode() : 0);
        hash = 89 * hash + (this.czona != null ? this.czona.hashCode() : 0);
        hash = 89 * hash + (this.semail != null ? this.semail.hashCode() : 0);
        hash = 89 * hash + (this.ncomercial != null ? this.ncomercial.hashCode() : 0);
        hash = 89 * hash + (this.nfolioIndice != null ? this.nfolioIndice.hashCode() : 0);
        hash = 89 * hash + (this.nsucursal != null ? this.nsucursal.hashCode() : 0);
        hash = 89 * hash + (this.snomComerSuc != null ? this.snomComerSuc.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final RcDomicilio other = (RcDomicilio) obj;
        if (this.ircDomicilio != other.ircDomicilio && (this.ircDomicilio == null || !this.ircDomicilio.equals(other.ircDomicilio))) {
            return false;
        }
        if ((this.nit == null) ? (other.nit != null) : !this.nit.equals(other.nit)) {
            return false;
        }
        if (this.tbDomicilio != other.tbDomicilio && (this.tbDomicilio == null || !this.tbDomicilio.equals(other.tbDomicilio))) {
            return false;
        }
        if (this.tbMunicipio != other.tbMunicipio && (this.tbMunicipio == null || !this.tbMunicipio.equals(other.tbMunicipio))) {
            return false;
        }
        if (this.fidomicilio != other.fidomicilio && (this.fidomicilio == null || !this.fidomicilio.equals(other.fidomicilio))) {
            return false;
        }
        if ((this.ddetalle == null) ? (other.ddetalle != null) : !this.ddetalle.equals(other.ddetalle)) {
            return false;
        }
        if ((this.scalle == null) ? (other.scalle != null) : !this.scalle.equals(other.scalle)) {
            return false;
        }
        if ((this.napto == null) ? (other.napto != null) : !this.napto.equals(other.napto)) {
            return false;
        }
        if ((this.scomplemento == null) ? (other.scomplemento != null) : !this.scomplemento.equals(other.scomplemento)) {
            return false;
        }
        if ((this.scolonia == null) ? (other.scolonia != null) : !this.scolonia.equals(other.scolonia)) {
            return false;
        }
        if ((this.nnumero == null) ? (other.nnumero != null) : !this.nnumero.equals(other.nnumero)) {
            return false;
        }
        if ((this.ntelefono == null) ? (other.ntelefono != null) : !this.ntelefono.equals(other.ntelefono)) {
            return false;
        }
        if ((this.nfax == null) ? (other.nfax != null) : !this.nfax.equals(other.nfax)) {
            return false;
        }
        if (this.ffdomicilio != other.ffdomicilio && (this.ffdomicilio == null || !this.ffdomicilio.equals(other.ffdomicilio))) {
            return false;
        }
        if ((this.cusuario == null) ? (other.cusuario != null) : !this.cusuario.equals(other.cusuario)) {
            return false;
        }
        if ((this.czona == null) ? (other.czona != null) : !this.czona.equals(other.czona)) {
            return false;
        }
        if ((this.semail == null) ? (other.semail != null) : !this.semail.equals(other.semail)) {
            return false;
        }
        if (this.ncomercial != other.ncomercial && (this.ncomercial == null || !this.ncomercial.equals(other.ncomercial))) {
            return false;
        }
        if ((this.nfolioIndice == null) ? (other.nfolioIndice != null) : !this.nfolioIndice.equals(other.nfolioIndice)) {
            return false;
        }
        if ((this.nsucursal == null) ? (other.nsucursal != null) : !this.nsucursal.equals(other.nsucursal)) {
            return false;
        }
        if ((this.snomComerSuc == null) ? (other.snomComerSuc != null) : !this.snomComerSuc.equals(other.snomComerSuc)) {
            return false;
        }
        return true;
    }

    

	
	
}
